/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package org.abc;

import java.util.Calendar;
import java.util.Date;

/**
 * <p>Project: jse2303 - Date1
 * <p>Powered by webrx On 2023-07-07 16:52:07
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Date1 {
    public static void main(String[] args) {
        //
        Date d = new Date(0);
        System.out.printf("%tF %<tT%n", d);

        System.out.println("------");
        Date d2 = new Date();
        long d3 = System.currentTimeMillis();
        Calendar d4 = Calendar.getInstance();
        System.out.printf("%tF %<tT%n", d2);
        System.out.printf("%tF %<tT%n", d3);
        System.out.printf("%tF %<tT%n", d4);

        //日历工具类的三个最常用的操作
        //d4.set(); 设置指定日期
        //d4.add(); 增加指定的数字
        //d4.get(); 获取信息

        System.out.println("------");

        //时间戳 long 数字表 毫秒数
        System.out.printf("%tF %<tT%n", System.currentTimeMillis());

        //计算两个日期有多少天 2001-10-20 16：57：30  到现在有多少天
        //实例化
        Calendar c = Calendar.getInstance();

        //设置指定的日期
        c.set(2023, Calendar.JULY, 1, 0, 0, 0);

        //获取日历实例的毫秒数long
        long ss = c.getTimeInMillis();

        //获取当前系统时间戳
        long nn = System.currentTimeMillis();
        long ok = nn - ss;
        //1天的毫秒数
        long day = 1000 * 60 * 60 * 24;
        long days = ok / day;
        //System.out.println(days);
        System.out.printf("%tY年%<tm月%<td日到%tY年%<tm月%<td日，共有%d天%n", ss, nn, days);


    }
}
